package com.wp.file.common;

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 */
public class BaseContext {
    //定义并赋值一个本地线程副本threadLocal
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    /**设定setCurrentId方法用来存入id的值*/
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }
    /**设定getCurrentId方法用来获取id的值*/
    public static Long getCurrentId(){
        return threadLocal.get();
    }

    /**设定管理员*/
    public static  void setCurrentAdminId(Long id){
        threadLocal.set(id);
    }
    public static Long getCurrentAdminId(){
        return threadLocal.get();
    }
}
